<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登陆页</title>
		<link rel="stylesheet" type="text/css" href="css/loading.css" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	</head>

	<body>
		<form action="" method="get">
			<input type="text" id="user" />
			<input type="password" id="psw" name="psw" />
			<input type="submit" id="submit" value="登陆" />
		</form>
		<script type="text/javascript">
			//为空校验
			(function() {
				var oBtn = document.querySelector("#submit");
				var user = document.querySelector("#user");
				var psw = document.querySelector("#psw");

				function isnull(val) {
					if(!user.value || !psw.value) {
						alert("草泥马！");
					}
				};
				oBtn.addEventListener("click", function() {
					isnull(user.value);
				})
			})();
		</script>
	</body>

</html>